package web;

import service.SmbmsUserService;
import service.impl.SmbmsUserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(value = "/deleteUserServlet")
public class DeleteUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        this.doPost(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
//调用业务层接口
//从界面获取id
        String id=req.getParameter("id");
        Long ids=Long.parseLong(id);
        SmbmsUserService smbmsUserService=new SmbmsUserServiceImpl();
        try {
            int i = smbmsUserService.deleteUser(ids);
            if(i>0){
//删除成功
                req.getRequestDispatcher("/userListServlet").forward(req,resp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

